import React, { Component } from "react";
import PropTypes from "prop-types";

import Item from "../Item";

import "./index.css";

export default class List extends Component {
    static propTypes = {
        todos: PropTypes.array.isRequired,
        deleteTodo: PropTypes.func.isRequired,
        changeTodo: PropTypes.func.isRequired,
    };

    render() {
        const { todos, deleteTodo, changeTodo } = this.props;

        return (
            <ul className="todo-main">
                {todos.map((todo) => (
                    <Item
                        key={todo.id}
                        {...todo}
                        deleteTodo={deleteTodo}
                        changeTodo={changeTodo}
                    />
                ))}
            </ul>
        );
    }
}
